package data;

import java.sql.Connection;
import java.sql.*;
import javax.swing.JOptionPane;

/**
 *
 * @author THOMAS
 */
public class Conexion {

    public static Connection getConexion(String sgbd){
        Connection con = null;
        try {
            if (sgbd.equals("SQL Server")) {
                Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
                con = DriverManager.getConnection("jdbc:sqlserver://HTMFLT:1433;database=test;user=isti;password=isti2012;");
            }
            if (sgbd.equals("MySQL")) {
                Class.forName("com.mysql.jdbc.Driver");
                con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","");
            }
            if (sgbd.equals("PostgreSQL")) {
                Class.forName("org.postgresql.Driver");
                con = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Empresarial","postgres","Marcos1014");
            }
        } catch (ClassNotFoundException | SQLException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
        return con;
    }
}